package entities;

import javax.swing.JLabel;

/** This is the main root if the inheritance of all the Objects placed on the playground.
 * @author Team 1
 *
 */
@SuppressWarnings("serial")
public abstract class Entity extends JLabel {
	
	protected float x;		//The  entity's upper left corner's x coordinate.
	protected float y;		//The entity's upper left corner's y coordinate.
	protected int width;	//The entity's width value.
	protected int height;	//The entity's height value.
	
	/** Entity's constructor.
	 * @param x : the entity's upper-left corner's x coordinate.
	 * @param y : the entity's upper-left corner's y coordinate.
	 */
	public Entity(int x, int y) {
		super();
		this.x = x;
		this.y = y;
	}
	
	/** Sets the entity's location within the playground.
	 * @param x : the entity's upper-left corner's x coordinate.
	 * @param y : the entity's upper-left corner's y coordinate.
	 */
	public void setLocation(int x, int y) {
		this.x = x;
		this.y = y;
		this.setBounds(Math.round(this.x), Math.round(this.y), width, height);
	}
	
	/** Sets the entity's x coordinate's value.
	 * @param x : the entity's new upper-left corner's x coordinate.
	 */
	public void setX(int x) {
		this.x = x;
	}
	
	/** Sets the entity's y coordinate's value.
	 * @param y : the entity's new upper-left corner's y coordinate.
	 */
	public void setY(int y) {
		this.y = y;
	}
	
	/** Gets the width value of the entity.
	 * @return the width value.
	 */
	public int getWidth() {
		return width;
	}
	
	/**  Gets the height value of the entity.
	 * @return the height value.
	 */
	public int getHeight() {
		return height;
	}
	
	/** Resize the boundaries of the entity provided the 
	 * @param xScale : The x scale. If it's lower than one it reduces the entity width, increase it otherwise.
	 * @param yScale : The y scale. If it's lower than one it reduces the entity height, increase it otherwise.
	 */
	public void resize(float xScale, float yScale) {
		this.x = Math.round(this.x * xScale);
		this.y = Math.round(this.y * yScale);
		this.width = Math.round(this.width * xScale);
		this.height = Math.round(this.height * yScale);
		this.setBounds(Math.round(x), Math.round(y), width, height);
	}
}
